home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / viewkit / VCal / main.c++ < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  3.6 KB  |  129 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #include "VCal.h"
  18. #include "PrintPS.h"
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <Vk/VkApp.h>
  22. #include <Vk/VkResource.h>
  23. #include <Vk/VkFatalErrorDialog.h>
  24.  
  25. static XrmOptionDescRec VCalOptions[] = {
  26.   {
  27.     "-file", "*defaultFilename", XrmoptionSepArg, NULL,
  28.   },
  29.   {
  30.     "-iconName", "*iconName", XrmoptionSepArg, NULL,
  31.   },
  32.   {
  33.     "-title", "*vcal.title", XrmoptionSepArg, NULL,
  34.   },
  35.   {
  36.     "-day", "*dayReport", XrmoptionSepArg, NULL,
  37.   },
  38.   {
  39.     "-week", "*weekReport", XrmoptionSepArg, NULL,
  40.   },
  41.   {
  42.     "-month", "*monthReport", XrmoptionSepArg, NULL,
  43.   },
  44.   {
  45.     "-printMonth", "*monthPrint", XrmoptionSepArg, NULL,
  46.   },
  47. };
  48.  
  49. void
  50. usage()
  51. {
  52.   fprintf(stderr, "Usage: vcal\n");
  53.   fprintf(stderr,
  54.       "         [-file database-file] [-iconName icon-name]\n");
  55.   fprintf(stderr,
  56.       "         [-scheme color-scheme] [-title window-title]\n");
  57.   fprintf(stderr,
  58.       "         [-day date] [-week date] [-month date]\n");
  59.   fprintf(stderr,
  60.       "         [-printMonth date]\n");
  61. }
  62.  
  63. void
  64. main(int argc, char **argv)
  65. {
  66.   char *str;
  67.   int day, month, year;
  68.  
  69.   VkApp *app = new VkApp("Vcal", &argc, argv,
  70.              VCalOptions, XtNumber(VCalOptions));
  71.  
  72.   if (app->argc() > 1) {
  73.     fprintf(stderr, "%s: Illegal argument '%s'\n", app->argv(0), app->argv(1));
  74.     usage();
  75.     exit(1);
  76.   }
  77.  
  78.   if (!VkGetResource(app->baseWidget(),
  79.              "vcalAppDefaults066", "VcalAppDefaults066")) {
  80.     theFatalErrorDialog->postAndWait("VCal app-defaults file missing or obsolete.\nInstall /usr/lib/X11/app-defaults/Vcal.");
  81.     exit(1);
  82.   }
  83.  
  84.   app->setVersionString("VCal, a simple calendar\nVersion 0.66\nApril 1994\n\nMike Yang\nmikey@sgi.com\nmikey@cs.stanford.edu\n\nCopyright 1994, Silicon Graphics, Inc.");
  85.   VCal *vcal = new VCal("vcal");
  86.  
  87.   vcal->show();
  88.  
  89.   if (str = XGetDefault(app->display(), app->argv(0), "dayReport")) {
  90.     if (parseDate(str, &day, &month, &year)) {
  91.       vcal->emitDay(stdout, day, month, year);
  92.       exit(0);
  93.     } else {
  94.       fprintf(stderr, "Unrecognized date: %s\n", str);
  95.       usage();
  96.       exit(1);
  97.     }
  98.   } else if (str = XGetDefault(app->display(), app->argv(0), "weekReport")) {
  99.     if (parseDate(str, &day, &month, &year)) {
  100.       vcal->emitWeek(stdout, day, month, year);
  101.       exit(0);
  102.     } else {
  103.       fprintf(stderr, "Unrecognized date: %s\n", str);
  104.       usage();
  105.       exit(1);
  106.     }
  107.   } else if (str = XGetDefault(app->display(), app->argv(0), "monthReport")) {
  108.     if (parseMonth(str, &month, &year)) {
  109.       vcal->emitMonth(stdout, day, month, year);
  110.       exit(0);
  111.     } else {
  112.       fprintf(stderr, "Unrecognized date: %s\n", str);
  113.       usage();
  114.       exit(1);
  115.     } 
  116.   } else if (str = XGetDefault(app->display(), app->argv(0), "monthPrint")) {
  117.     if (parseMonth(str, &month, &year)) {
  118.       vcal->getPrint()->printMonth(stdout, month, year);
  119.       exit(0);
  120.     } else {
  121.       fprintf(stderr, "Unrecognized date: %s\n", str);
  122.       usage();
  123.       exit(1);
  124.     }
  125.  }
  126.  
  127.   app->run();
  128. }
  129.